package com.kakame.codenews.base.web.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 * <pre>
 * <b>desc:</b> 用户请求拦截器 
 * <b>auth:</b> 何家明
 * <b>date:</b> 2018年6月1日 上午10:23:06
 * </pre>
 */
public class RequestInterceptor implements HandlerInterceptor {

    private Logger logger = LoggerFactory.getLogger(this.getClass().getPackage().getName());
    
    /**
     * 在调用controller方法前拦截
     */
    @Override
    public boolean preHandle(HttpServletRequest request,
            HttpServletResponse response, Object handler) throws Exception {
        String requestURI = request.getRequestURI();
        logger.info("请求uri：" + requestURI);
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request,
            HttpServletResponse response, Object handler,
            ModelAndView modelAndView) throws Exception {
    }

    @Override
    public void afterCompletion(HttpServletRequest request,
            HttpServletResponse response, Object handler, Exception ex)
            throws Exception {
    }
}
